<?php
/**
 * Administrator Group Form
 *
 * @category   Cms
 * @package    Cms_Form
 */
class Cms_Form_Administrator_Group_Form extends BIS_Form_Abstract
{
    public function init()
    {
        $this->addElementPrefixPath('Cms_Decorator',
                            	     APPLICATION_PATH . '/modules/cms/models/decorator/',
                            	    'decorator');
        
        $this->setMethod('post');
        $this->setAction('');

        $resourceService = new Cms_Service_Resource();
        $resourceAccessPermissions = $resourceService->getAccessPermissions();
        $resourceModifyPermissions = $resourceService->getModifyPermissions();

        $accessPermission = array();
        foreach($resourceAccessPermissions as $resourceAccessPermission) {
            $accessPermission[$resourceAccessPermission] = $resourceAccessPermission;
        }

        $modifyPermission = array();
        foreach($resourceModifyPermissions as $resourceModifyPermission) {
            $modifyPermission[$resourceModifyPermission] = $resourceModifyPermission;
        }

        $this->addElement('text', 'name', array(
            'label' => 'Administrator Group Name',
            'size' => 30,
            'filters' => array('StringTrim'),
            'required' => true
        ));
        
        $this->addElement('multiselect', 'accessPermission', array(
            'label' => 'Access Permission',
            'filters' => array('StringTrim'),
            'multiOptions' => $accessPermission
        ));

         $this->addElement('multiselect', 'modifyPermission', array(
            'label' => 'Modify Permission',
            'filters' => array('StringTrim'),
            'multiOptions' => $modifyPermission
        ));
        
        $this->setElementDecorators(array(
            'ViewHelper',
            'FormElementsErrors',
             array(array('data' => 'HtmlTag'),  array('tag' =>'td')),
              'FormElementsLabel',
            array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
        ));

        $this->setDecorators(array(
            'FormElements',
            array('HtmlTag', array('tag' => 'table', 'class'=> 'form')),
            'Form'
        ));

    }
}